-- Function: comum.calcular(numeric, numeric, character)

-- DROP FUNCTION comum.calcular(numeric, numeric, character);

CREATE OR REPLACE FUNCTION comum.calcular(v_a numeric, v_b numeric, p_operador character)
  RETURNS numeric AS
$BODY$
  DECLARE
    v_retorno numeric;

    --v_idaluno aluno.identerp%TYPE;

    v_aluno RECORD;
--    v_aluno aluno%ROWTYPE;

/*
   v_alunos RECORD;
   c_alunos CURSOR IS
     SELECT *
       FROM alunocompl
       LIMIT 100;
*/
  BEGIN

/*
    OPEN c_alunos;  
    LOOP 
      FETCH c_alunos INTO v_alunos;
      IF FOUND THEN
        -- processar
        IF v_alunos.nomaluno ILIKE '%FAVA%' THEN
          RAISE NOTICE '%', v_alunos;
        END IF;
      ELSE
        EXIT;
      END IF;
    END LOOP;
    CLOSE c_alunos;  
*/
    RETURN v_retorno;

  END;
$BODY$
  LANGUAGE 'plpgsql' VOLATILE;
ALTER FUNCTION comum.calcular(numeric, numeric, character) OWNER TO postgres;
